<?php

// sets the current page and language
if (isset($_GET['page']) && in_array($_GET['page'], $pages))
    $currentPage = $_GET['page'];
else // illegal page name
    $currentPage = PAGE;     // default value

if (isset($_GET['lang']) && in_array($_GET['page'], $languages))   // either first visit or error
    $lang = $_GET['lang'];
else
    $lang = LANG;     // default value
    
if (isset($_GET['brand']))   // either first visit or error
    $brand = $_GET['brand'];
else
    if ($currentPage == 'audio')
        $brand = BRAND_AUDIO;     // default value
    elseif  ($currentPage == 'video')
        $brand = BRAND_VIDEO;     // default value
    elseif  ($currentPage == 'connection')
        $brand = BRAND_CONNECTION;     // default value

// creates the model, retrieves translated texts and prepares user data
$model = Model::getInstance();
$model->translate($lang);       // gets all translated textes form the DB
$model->prepareData();          // prepares the data to be displayed on the current page

// creates the controller and checks user data
$controller = Controller::getInstance();
if ($controller->checkData())       // checks if the form's entered data are correct, returns "false" if no form
    $controller->proceed();         // form's entered data proccessing